package com.hys.enums;

/**
 * 合作状态展示枚举
 * @author chufangzheng
 */
public enum CoopStatusEnum {

    BUILD(1, "待审批"),
    AUDITING(2, "审批中"),
    PASSED(3, "已通过"),
    REJECTED(4, "已拒绝");

    private final Integer code;
    private final String desc;

    CoopStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static Boolean isAbleUpdate(Integer code){
        if(code.equals(BUILD.code) ||
                code.equals(REJECTED.code)){
            return true;
        }else{
            return false;
        }
    }

    public static Boolean isAbleDelete(Integer code){
        if(code.equals(BUILD.code) ||
                code.equals(REJECTED.code)){
            return true;
        }else{
            return false;
        }
    }

    public static CoopStatusEnum getByCode(Integer code) {
        for (CoopStatusEnum status : CoopStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return desc;
    }

}
